﻿@using WaterRevenueMS.Domain.ViewModels.Settlement;
@using WaterRevenueMS.Domain.ViewModels.AdminCommon
@model SettlementModel
@{
    ViewBag.Title = ViewBag.CurrentTitle + " - 潍微水务管理系统";
    var editButton = new ButtonModel();
    var deleteButton = new ButtonModel();
    editButton = ViewBag.Edit;
    deleteButton = ViewBag.Delete;
}
@section css{
     <link href="@Url.Content("~/Content/themes/base/jquery.ui.core.css")" rel="Stylesheet" type="text/css"/>  
     <link href="@Url.Content("~/Content/themes/base/jquery.ui.autocomplete.css")" rel="Stylesheet" type="text/css"/> 
     <link href="@Url.Content("~/Content/themes/base/jquery.ui.datepicker.css")" rel="Stylesheet" type="text/css"/> 
     <link href="@Url.Content("~/Content/themes/base/jquery.ui.theme.css")" rel="Stylesheet" type="text/css"/> 
}

<div id="content-body" class="row-fluid">
    <div class="span22">
        <!--操作 -->
        @Html.Partial("Search", Model.Search)

        <!--列表-->
        @Html.Partial("List")

        <!--新增 & 编辑-->
        @Html.Partial("_FormModal")
    
    </div>
</div>

@section scripts{
    <script src="@Url.Content("~/Scripts/jquery-ui-1.10.4.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui-zh.js")" type="text/javascript"></script>
    <script type="text/javascript">
        var oTable = null;

        $(function () {
            var actionUrl = "@Url.Action("List")?rand=" + Math.random();
            var aoColumns = [
                    { "sName": "SortId", "bSortable": false },
                    
                    { "sName": "Hu_ZXM", "bSortable": false },
                    { "sName": "Yong_HBH", "bSortable": false },
                    { "sName": "Yi_BBH", "bSortable": false },
                    { "sName": "Yi_BDZ", "bSortable": false },
                    { "sName": "Du_SBQ", "bSortable": false },
                    { "sName": "Du_SBC", "bSortable": false },
                    { "sName": "Chao_BDTBC", "bSortable": false },
                    { "sName": "Yong_LBC", "bSortable": false },
                    { "sName": "Ji_FBC", "bSortable": false },
                    { "sName": "Shi_FJS", "bSortable": false },
                    {
                        "sName": "Id",
                        "bSearchable": false,
                        "bSortable": false,
                        "fnRender": function (oObj) {
                            var btnArray = "";
                            @if (editButton != null)
                            {
                                <text>btnArray += '<button type="submit" class="btn btn-primary btn-normal" title="@editButton.Text" onclick="Edit(' + oObj.aData[oObj.aData.length - 1] + ')"><span class="@editButton.Icon"></span></button>'</text>
                            }
                            return btnArray;
                        }
                    }
            ];
            //初始化表格
            oTable = InitDatatables($(".data-table"), actionUrl, aoColumns, oTable);
        });

                //查询
        function Search() {
                    var filterdata = $(".search-form").serialize();
                    var actionUrl = "@Url.Action("List")?rand=" + Math.random() + "&" + filterdata;
            SearchRecord(actionUrl, oTable);
        }
        function Settlement(){
            var filterdata=$(".search-form").serialize();

            $.ajax({
                url: "/Settlement/ChargeSettlement?"+filterdata,
                type: "get",
                cache: false,
                dataType: 'json',
                success: function (data) {
                  Search();
                },
                error: function () {
                   
                }
            });

        }
        //新增
        function Create() {
            var actionUrl = "@Url.Action("Create")";
            var param = {};
            ShowModal(actionUrl, param, "新增编码规则");
        }

        //编辑
        function Edit(id) {
            var actionUrl = "@Url.Action("Edit")";
            var param = { Id: id }
            ShowModal(actionUrl, param, "编辑编码规则");
        }

        //保存
        function Save() {
            SaveModal(oTable);
        }

        //删除
        function Delete(id) {
            var actionUrl = "@Url.Action("Delete")";
            var param = { Id: id }
            DeleteRecord(actionUrl, param, oTable);
        }
    </script>
}



